<?php
/**
 * 地区模型
 * User: fenglangyj
 * DateTime:   2013-10-11 11:10:37
 * To change this template use File | Settings | File Templates.
 */
class region_model extends  SDF_Model
{
    var $title = '';
    var $content = '';
    var $date = '';
    public function __construct(){
        $this->db = $this->load->database('default',true);
        parent::__construct();
    }

    /**
     * 获取地区
     * @param int $parent_id
     * @return array
     */
    public function get_region_names($parent_id=1){
        $region_arr = $this->db->select('region_id,region_name')->get_where('region',array('parent_id'=>$parent_id))->result_array();
        $region_names = array();
        foreach($region_arr as $user){
            //$region_names[$user['region_id']] = $user['region_id'].'| '.$user['region_name'];
            $region_names[$user['region_id']] = $user['region_name'];
        }
        return $region_names;
    }
}
